import { getRandomDateTime, getNowDate, getFeatureDate } from '../../../../utils'
import Mock from 'mockjs'
export const smsLogMock = pageSize => {
  const result: any[] = []
  const codeList = ['TENCENT', 'HUAWEI', 'QINIU', 'ALIYUN', 'DEBUG_DING_TALK']
  for (let i = 0; i < pageSize; i++) {
    const res = getTemplateContentAndParams()
    result.push({
      id: i + 1,
      channelId: Mock.mock('@integer(1, 100)'),
      channelCode: codeList[Mock.mock('@integer(0, 4)')],
      templateType: Mock.mock('@integer(1, 3)'),
      apiTemplateId: Mock.mock('@id'),
      mobile: /1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}/,
      apiSendCode: Mock.mock('@word'),
      apiSendMsg: Mock.mock('@cword'),
      apiRequestId: Mock.mock('@id'),
      apiSerialNo: Mock.mock('@word'),
      receiveStatus: Mock.mock('@integer(1, 3)'),
      receiveTime: getRandomDateTime(getFeatureDate(-10), getNowDate()),
      apiReceiveCode: Mock.mock('@word'),
      apiReceiveMsg: Mock.mock('@cword'),
      userId: Mock.mock('@integer(1, 100)'),
      userType: Mock.mock('@integer(1, 2)'),
      templateId: Mock.mock('@integer(1, 100)'),
      templateCode: Mock.mock('@word'),
      templateContent: res.templateContent,
      templateParams: res.templateParams,
      sendStatus: Mock.mock('@integer(1, 4)'),
      sendTime: getRandomDateTime(getFeatureDate(-10), getNowDate()),
      creator: '1',
      create_time: getRandomDateTime(getFeatureDate(-10), getNowDate()),
      updater: '',
      update_time: '',
      deleted: false,
      deleted_time: ''
    })
  }
  return result
}

const getTemplateContentAndParams = () => {
  const len = Mock.mock('@integer(1, 4)')
  const res: any = {
    templateContent: '',
    templateParams: []
  }
  for (var i = 0; i < len; i++) {
    const param = Mock.mock('@word')
    const text = Mock.mock('@ctitle')
    res.templateParams.push(param)
    if (i % 2 === 0) {
      res.templateContent += '{' + param + '}，' + text + '，'
    } else {
      res.templateContent += text + '{' + param + '}' + '。'
    }
  }
  return res
}
